package com.smh.a06regexDemo6;

public class RegexDemo3 {
    public static void main(String[] args) {
        //将第一组的数据再用一次(首位一位相同)
        String regex = "(.).+\\1";
        System.out.println("aasdasa".matches(regex));
        System.out.println("aasdasb".matches(regex));
        System.out.println("a1213a".matches(regex));
        System.out.println("aa345345sa".matches(regex));
        System.out.println("-------------------------------");
        //首位有相同的数据,不对称
        String regex2 = "(.+).+\\1";
        System.out.println("aasdasa".matches(regex2));
        System.out.println("absdaab".matches(regex2));
        System.out.println("a1213a".matches(regex2));
        System.out.println("aa345345aa".matches(regex2));
        System.out.println("-------------");
        //匹配首位相同且首的个元素也相同
        String regex3 = "((.)\\2*).+\\1";
        System.out.println("aa124aa".matches(regex3));
        System.out.println("a124aa".matches(regex3));
        System.out.println("ab124ba".matches(regex3));
        System.out.println("ca124aa".matches(regex3));

    }


}
